<?php

use App\Models\UserDcoinsLog;

return [
    'title'   => 'D币管理',
    'heading' => 'D币管理',
    'single'  => 'D币管理',
    'model'   => UserDcoinsLog::class,


    'columns' => [
        'user_id' => [
            'title' => '用户ID',
        ],

        'user' => [
            'title'    => '用户',
            'sortable' => false,
            'output'   => function ($value, $model) {

                $avatar = $model->user->present()->gravatar();
                $value = empty($avatar) ? 'N/A' : '<img src="'.$avatar.'" style="height:44px;width:44px"> ' . $model->user->name;

                return model_link($value, 'users', $model->user_id);
            },
        ],
        'remain_dcoins' => [
            'title' => '剩余D币',
        ],
        'dcoins' => [
            'title' => '变更D币',
        ],
        'type' => [
            'title' => '变更类型',
            'output' => function ($value) {
                if ($value == 1)
                { return '增加';}
                elseif ($value == 2)
                {return '消耗';}
            },
        ],
        'reason_type' => [
            'title' => '变更原因',
            'output' => function($value) {
                if ($value == 1)
                { return '赞助';}
                elseif ($value == 2)
                {return '作业帮有偿求助';}
                elseif ($value == 3)
                {return '算法外包发帖';}
                elseif ($value == 4)
                {return 'D币转化为积分';}
                elseif ($value == 5)
                {return '人为修改';}
                elseif ($value == 6)
                {return '下载资源';}
                elseif ($value == 7)
                {return '资源被下载';}
                elseif ($value == 8)
                {return '作业帮消耗';}
                elseif ($value == 9)
                {return '作业帮增加';}
            },
        ],
        'remark' => [
            'title' => '备注',
        ],
        'updated_at' => [
            'title' => '变更时间',
            'sortable' => true,
        ],
        'operation' => [
            'title'  => '管理',
            'output' => function ($value, $model) {
                return $value;
            },
            'sortable' => false,
        ],
    ],
    'edit_fields' => [
        'user_id' => [
            'title' => '用户ID',
        ],
        'remain_dcoins' => [
            'title' => '剩余D币(需要手工加上或减去)',
        ],
        'dcoins' => [
            'title' => '变更D币(正数:增加,负数:消耗)',
        ],
        'type' => [
            'title' => '变更类型(1:增加,2:消耗)',
            'value' => 1,
        ],
        'reason_type' => [
            'title' => '变更原因(1:赞助,2:作业帮有偿,3:算法外包发帖,4:D币转换为积分,5:人为修改,6:下载资源,7:资源被下载，8:作业帮消耗,9:作业帮增加)',
            'value' => 1,
        ],
        'remark' => [
            'title' => '备注',
        ],
    ],
    'filters' => [
        'user_id' => [
            'title' => '用户ID',
        ],
        'type' => [
            'title' => '变更类型(1:增加,2:消耗)',
        ],
        'reason_type' => [
            'title' => '变更原因(1:赞助,2:作业帮有偿,3:算法外包发帖,4:D币转换为积分,5:人为修改,6:下载资源,7:资源被下载,8:作业帮消耗,9:作业帮增加)',
        ],
        'updated_at' => [
            'type' => 'datetime',
            'title' => '查询时间',
        ],
    ],
];
